<?php

use Phinx\Migration\AbstractMigration;

class CreateSystemNotifyMessageDetailTable extends AbstractMigration
{
    public function up()
    {
        $this->table("system_notify_message_detail", ['id' => false, 'primary_key' => ['id'], 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '系统统计通知信息详情'])
            ->addColumn('id', 'integer', ['identity' => true, 'signed' => false, 'limit' => 11, 'comment' => '主键ID'])
            ->addColumn('message_id', 'integer', ['signed' => false, 'limit' => 11, 'comment' => '关联的统计消息id'])
            ->addColumn('link_id', 'integer', ['signed' => false, 'default' => 0, 'limit' => 11, 'comment' => '关联id'])
            ->addColumn('link_type', 'string', ['default' => '', 'limit' => 120, 'comment' => '关联类型'])
            ->addColumn('type', 'enum', ['default' => 'warning', 'values' => "warning,out_date", 'comment' => '父级消息类型(逾期 还是预警)'])
            ->addColumn('message_content', 'json', ['null' => true, 'comment' => "详情消息内容",])
            ->addColumn('created', 'integer', ['signed' => false, 'default' => 0, 'limit' => 11, 'comment' => '创建时间'])
            ->create();
    }

    public function down()
    {
        $this->table("system_notify_message_detail")
            ->drop()
            ->save();
    }
}
